#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct vertex {
	int vername;
	struct edge* adjacent;
};
struct edge {
	int veradj;
	edge* link;
};
struct vertex head[20010];
int visited[20010];
struct edge* newedge;
struct edge* ptr;
void build(int a, int b) {
	newedge = (struct edge*)malloc(sizeof(struct edge));
	newedge->veradj = b;
	newedge->link = NULL;
	if (head[a].adjacent == NULL) head[a].adjacent = newedge;
	else {
		ptr = head[a].adjacent;
		while (ptr->link != NULL) {
			ptr = ptr->link;
		}
		ptr->link = newedge;
	}
}
void visit(int n) { printf("%d ", n); }
void dfs(vertex head[], int v, int visited[]) {
	visit(v); visited[v] = 1;
	for (edge* p = head[v].adjacent; p != NULL; p = p->link) {
		int k = p->veradj;
		if (visited[k]==0) dfs(head, k, visited);
	}
}
int main() {
	int n, e;
	scanf("%d %d", &n, &e);
	int value[55][2];
	int i;
	for (i = 0; i < e; i++) {
		scanf("%d %d", &value[i][0], &value[i][1]);
	}
	for (i = 0; i < n; i++) {
		head[i].vername = i;
		head[i].adjacent = NULL;
		visited[i] = 0;
	}
	for (i = 0; i < e; i++) {
		build(value[i][0], value[i][1]);
	}
	for (i = 0; i < n; i++)
		if (visited[i] == 0)
			dfs(head, i, visited);
	return 0;

}